home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / gzip 1.2.2 / zcmp.mac < prev    next >
Encoding:
Text File  |  1993-07-11  |  1.8 KB  |  73 lines  |  [TEXT/MPS ]

  1. #
  2. # znew.mac -- znew for MPW
  3. #
  4. # written by Anthony C. Ard, 1993
  5. #
  6. # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh
  7.  
  8. # Zcmp and zdiff are used to invoke the cmp or the  diff  pro-
  9. # gram  on compressed files.  All options specified are passed
  10. # directly to cmp or diff.  If only 1 file is specified,  then
  11. # the  files  compared  are file1 and an uncompressed file1.gz.
  12. # If two files are specified, then they are  uncompressed  (if
  13. # necessary) and fed to cmp or diff.  The exit status from cmp
  14. # or diff is preserved.
  15.  
  16. set prog `echo {0} | sed 's|.*/||'`
  17.  
  18. if "{prog}" =~ /≈cmp/
  19.     set comp compare
  20. else if "{prog}" =~ /≈diff/
  21.     set comp diff
  22. end
  23.  
  24. unset OPTIONS
  25. unset FILES
  26. set exit 0
  27.  
  28. for arg in {Parameters}
  29.     if "{arg}" =~ /-≈/
  30.         set OPTIONS "{OPTIONS} {arg}"
  31.     else
  32.         set FILES "{FILES} {arg}"
  33.     end
  34. end
  35.  
  36. if "{FILES}" == ""
  37.     echo "Usage: {prog} [{comp}_options] file [file]"
  38.     exit 1
  39. end
  40.  
  41. if {#} == 1
  42.     set FILE `echo "{1}" | sed 's/[-.][zZtga]*$//'`
  43.     gzip -cd "{1}" | {comp} {OPTIONS} "{FILE}"
  44.     set STAT {Status}
  45. else if {#} == 2
  46.     if "{1}" =~ /≈[-.]gz/ || "{1}" =~ /≈[-.][zZ]/ || "{1}" =~ /≈.t[ga]z/
  47.         if "{2}" =~ /≈[-.]gz/ || "{2}" =~ /≈[-.][zZ]/ || "{2}" =~ /≈.t[ga]z/
  48.             set F `echo "{2}" | sed 's|.*/||;s|[-.][zZtga]*$||'`
  49.                         gzip -cd "{2}" > "{TempFolder}{F}"
  50.                         gzip -cd "{1}" | {comp} {OPTIONS} "{TempFolder}{F}"
  51.                         set STAT {Status}
  52.             delete -y "{TempFolder}{F}"
  53.         else
  54.             gzip -cd "{1}" | {comp} {OPTIONS} "{2}"
  55.             set STAT {Status}
  56.         end
  57.     else
  58.         if "{2}" =~ /≈[-.]gz/ || "{2}" =~ /≈[-.][zZ]/ || "{2}" =~ /≈.t[ga]z/
  59.             gzip -cd "{2}" | {comp} {OPTIONS} "{1}"
  60.             set STAT {Status}
  61.         else
  62.             {comp} {OPTIONS} "{1}" "{2}"
  63.             set STAT {Status}
  64.         end
  65.     end
  66. else
  67.     echo "Usage: {prog} [{comp}_options] file [file]"
  68.     set STAT 1
  69. end
  70.  
  71. set exit 1
  72. exit {STAT}
  73.